package com.lp.business.domain;

import java.util.HashMap;

/**
 * 类Result的功能描述:
 * 返回数据实体类
 *
 * @auther lipeng
 * @date 2018-08-22 11:57:50
 */
public class Result extends HashMap<String, Object> {

	private static final long serialVersionUID = 1L;
	
	@Override
	public Result put(String key, Object value) {
		super.put(key, value);
		return this;
	}
	
	public static Result ok() {
		return ok("成功");
	}
	
	public static Result ok(String msg) {
		Result result = new Result();
		result.put("code", StatusCode.SUCCESS.getDesc());
		result.put("msg", msg);
		return result;
	}
	
	public static Result error() {
		return error("失败");
	}
	
	public static Result error(String msg) {
		return error(StatusCode.FAILURE.getDesc(), msg);
	}
	
	public static Result error(String code, String msg) {
		Result result = new Result();
		result.put("code", code);
		result.put("msg", msg);
		return result;
	}

//	public Result ok(Map<String, Object> map) {
//		Result r = new Result();
//		r.putAll(map);
//		return r;
//	}
//	
}

